package org.huangrui.spark.java.core.rdd.operate.action;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

/**
 * @Author hr
 * @Create 2024-10-18 9:47
 */
public class Spark03_Operate_Action_2_IOSave {
    public static void main(String[] args) {
        final SparkConf conf = new SparkConf().setMaster("local[*]").setAppName("spark");
        final JavaSparkContext jsc = new JavaSparkContext(conf);
        final List<Integer> nums = Arrays.asList(4, 2, 3, 1);
        final JavaRDD<Integer> rdd = jsc.parallelize(nums, 2);

        // 保存
        rdd.saveAsTextFile("output");
        rdd.saveAsObjectFile("output1");

        jsc.close();
    }
}
